package com.homer.android.sdk.devcie.bulider;

import com.homer.android.sdk.devcie.IEspDeviceRoot;
import com.homer.android.sdk.type.devcie.state.EspDeviceState;
import com.homer.android.sdk.util.RandomUtil;
import com.homer.iot.esptouch.model.EspDeviceRoot;
import com.homer.iot.esptouch.udp.EspDeviceType;


public class BEspDeviceRoot implements IBEspDeviceRoot
{
    private IEspDeviceRoot localRoot = null;
    private IEspDeviceRoot internetRoot = null;
    private IEspDeviceRoot virtualMeshRoot = null;
    
    private BEspDeviceRoot()
    {
        localRoot = new EspDeviceRoot();
        EspDeviceState stateLocal = new EspDeviceState();
        stateLocal.addStateLocal();
        localRoot.setDeviceState(stateLocal);
        localRoot.setDeviceType(EspDeviceType.ROOT);
        localRoot.setDeviceNumber(RandomUtil.randomString(20));
        localRoot.setId(Long.MIN_VALUE);
        
        internetRoot = new EspDeviceRoot();
        EspDeviceState stateInternet = new EspDeviceState();
        stateInternet.addStateInternet();
        internetRoot.setDeviceState(stateInternet);
        internetRoot.setDeviceType(EspDeviceType.ROOT);
        internetRoot.setDeviceNumber(RandomUtil.randomString(20));
        internetRoot.setId(Long.MIN_VALUE + 1);
        
        virtualMeshRoot = new EspDeviceRoot();
        EspDeviceState stateMesh = new EspDeviceState();
        stateMesh.addStateLocal();
        stateMesh.addStateInternet();
        virtualMeshRoot.setDeviceState(stateMesh);
        virtualMeshRoot.setDeviceType(EspDeviceType.ROOT);
        virtualMeshRoot.setDeviceNumber(RandomUtil.randomString(20));
        virtualMeshRoot.setId(Long.MIN_VALUE + 2);
    }
    
    private static class InstanceHolder
    {
        static BEspDeviceRoot instanceBuilder = new BEspDeviceRoot();
    }
    
    public static BEspDeviceRoot getBuilder()
    {
        return InstanceHolder.instanceBuilder;
    }
    
    @Override
    public IEspDeviceRoot getLocalRoot()
    {
        return localRoot;
    }

    @Override
    public IEspDeviceRoot getInternetRoot()
    {
        return internetRoot;
    }

    @Override
    public IEspDeviceRoot getVirtualMeshRoot()
    {
        return virtualMeshRoot;
    }
}

